import 'package:lishopflu/base/view_import.dart';

import 'login_ctl.dart';


class LoginPage extends BasePage<LoginCtl>{
  @override
  void onCreate(BuildContext mContext) {

  }

  @override
  Widget pageBody(BuildContext context) {
    return Center(
        child: SingleChildScrollView(
          child: Container(
            padding: EdgeInsets.only(left: 30,right: 30),
            child: Form(
              key: controller.globalKey.value,
              child: Column(
                children: <Widget>[

                  Text('登录到`LiShop`',style: TextStyle(fontSize: 24),),

                  Padding(padding: EdgeInsets.only(top: 30)),

                  TextFormField(
                      controller: controller.controller1.value,
                      decoration: InputDecoration(
                        labelText: '账号：',
//                      helperText: '账号长度至少3位！',
                        hintText: '请输入账号',
                        prefixIcon: Icon(Icons.account_box),
                      ),
                      validator: (v) {
                        return v.trim().length >= 3 ? null : "账号长度至少3位！";
                      }
                  ),

                  TextFormField(
                      controller: controller.controller2.value,
                      obscureText: true,
                      decoration: InputDecoration(
                        labelText: '密码：',
//                      helperText: '密码长度至少6位！',
                        hintText: '请输入密码',
                        prefixIcon: Icon(Icons.lock_outline),
                      ),
                      validator: (v) {
                        return v.trim().length >= 6 ? null : "密码长度至少6位！";
                      }
                  ),

                  Padding(padding: EdgeInsets.only(top: 30)),

                  MaterialButton(
                    minWidth: double.infinity,
                    color: Colors.green,
                    child: Text('登录'),
                    onPressed: (){
                      controller.login();
                    },
                  ),

                  Padding(padding: EdgeInsets.only(top: 20)),

                  MaterialButton(
                    minWidth: double.infinity,
                    color: Colors.green,
                    child: Text('还没账号？去注册'),
                    onPressed: (){
                      controller.toRegister();
                    },
                  ),

                  Padding(padding: EdgeInsets.only(top: 20)),

                  MaterialButton(
                    minWidth: double.infinity,
                    color: Colors.green,
                    child: Text('游客进入'),
                    onPressed: (){
                      controller.toMain();
                    },
                  ),

                ],
              ),
            ),
          ),
        )
    );
  }

}